package emulator.unittest.hardware.memory;


import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import emulator.EmulatorException;
import emulator.hardware.memory.DebugMemoryBlock;

public class DebugMemoryBlockReadonlyTest {
	
	private DebugMemoryBlock memory;

	@Before
	public void setUp() throws Exception {
		memory = new DebugMemoryBlock(0x1000);
		memory.enableReadonly(0x200, 0x2ff, true);
	}
	
	@Test
	public void testReadWriteBelow() throws EmulatorException
	{
		int address = 0x1FF;
		memory.write(address, 0x55);
		assertEquals(0x55, memory.read(address));
	}

	@Test
	public void testReadWriteStart() throws EmulatorException
	{
		int address = 0x200;
		memory.write(address, 0x55);
		assertEquals(0, memory.read(address));
	}

	@Test
	public void testReadWriteStop() throws EmulatorException
	{
		int address = 0x2FF;
		memory.write(address, 0x55);
		assertEquals(0, memory.read(address));
	}

	@Test
	public void testReadWriteAbove() throws EmulatorException
	{
		int address = 0x300;
		memory.write(address, 0x55);
		assertEquals(0x55, memory.read(address));
	}

}
